package sch.frog.utils.mail;

import java.io.File;

/**
 * 
 * @author Frog
 * 邮件附件类
 */
public class AttachFile {
	private String cid;	//邮件附件的content-id(可选)
	private String fileName;	//附件的文件名(可选)
	private File file;	//文件本体
	public String getCid() {
		return cid;
	}
	public void setCid(String cid) {
		this.cid = cid;
	}
	public String getFileName() {
		if(fileName == null){
			fileName = file.getName();
		}
		return fileName;
	}
	public void setFileName(String fileName) {
		int dotIndex = fileName.lastIndexOf(".");
		if(dotIndex == -1){
			int fileDotIndex = file.getName().lastIndexOf(".");
			if(fileDotIndex == -1){
				this.fileName = fileName;
			}else{
				String suffix = file.getName().substring(fileDotIndex);
				this.fileName = fileName + suffix; 
			}
		}else{
			this.fileName = fileName;
		}
	}
	public File getFile() {
		return file;
	}
	public void setFile(File file) {
		this.file = file;
	}
	public AttachFile(File file) {
		super();
		this.file = file;
	}
}
